#include <stdio.h>

#define IP_CAPACITY 4

typedef struct
{
    char *from;
    char *to;
    char *msg;
} IP;

int main(void);
void fill_ip_pdu(IP *ips, char **from, char **to, char **messgs);
void print_ip(IP ip);

int main(void)
{
    IP ips[IP_CAPACITY] = {0};
    char *messages[IP_CAPACITY] = {
        "Hola",
        "Buenos días",
        "cómo",
        "está usted",
    };
    char *from[IP_CAPACITY] = {
        "Fulanito",
        "Menganito",
        "Pepito",
        "Juanito",
    };
    char *to[IP_CAPACITY] = {
        "Pepe",
        "Juan",
        "Inés",
        "Rodrigo",
    };

    //Rellenar tramas IP
    fill_ip_pdu(ips, from, to, messages);

    //Imprimir tramas IP
    for (int i = 0; i < IP_CAPACITY; ++i)
        print_ip(ips[i]);

    return 0;
}

void fill_ip_pdu(IP *ips, char **from, char **to, char **messgs)
{
    for(int i = 0; i < IP_CAPACITY; ++i)
    {
        ips[i] = (IP) {
            .from = from[i],
            .to = to[i],
            .msg = messgs[i]
        };
    }
}

void print_ip(IP ip)
{
    printf("\n-------- IP MESSAGE START --------\n");
    printf("From\t= %s\nTo\t= %s\nMessage\t= %s\n", ip.from, ip.to, ip.msg);
    printf("-------- IP MESSAGE END --------\n");
}
